<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:c="http://java.sun.com/jstl/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	template="/template/template.xhtml"
	xmlns:o="http://omnifaces.org/ui"
	xmlns:of="http://omnifaces.org/functions">

	<ui:define name="styleAndScript"></ui:define>
	<ui:define name="center_content">
		<p:breadCrumb>
			<p:menuitem value="首页" url="/faces/index.xhtml" />
			<p:menuitem value="角色管理" url="#" />
		</p:breadCrumb>
		<h:form prependId="false" id="main_form">
			<div class="style1">
				<h:panelGrid columns="6" columnClasses="column1,column2,column1,column2,column1,column2">
					<h:outputText value="编号：" />
					<p:inputText value="#{roleBean.queryMap['code']}" />
					<h:outputText value="名称：" />
					<p:inputText value="#{roleBean.queryMap['name']}" />
		        </h:panelGrid>
		        <div>
		        	<p:commandButton value="#{msgs.btnQuery}" icon="#{comm.queryClass}" 
		        		action="#{roleBean.search}" update=":main_form:role_data_table"
		        		disabled="#{!roleBean.permission.query}"/>
		        	<p:commandButton value="#{msgs.btnReset}" icon="#{comm.resetClass}" type="reset"/>
		        </div>
			</div>
	
			<p:contextMenu for="role_data_table">
				<p:menuitem value="#{msgs.btnQuery}" icon="#{comm.queryClass}" 
					 oncomplete="role_edit_var.show();" update=":role_edit_dialog"
					 disabled="#{!roleBean.permission.query}">
					<f:setPropertyActionListener target="#{roleBean.model}" value="#{comm.m_q}" />
					<f:setPropertyActionListener target="#{roleBean.summary}" value="查询角色信息：" />
				</p:menuitem>
				<p:menuitem value="#{msgs.btnEdit}" icon="#{comm.editClass}"
					oncomplete="role_edit_var.show();" update=":role_edit_dialog"
					disabled="#{!roleBean.permission.modify}">
					<f:setPropertyActionListener target="#{roleBean.model}" value="#{comm.m_m}" />
					<f:setPropertyActionListener target="#{roleBean.summary}" value="编辑角色信息：" />
				</p:menuitem>
			</p:contextMenu>
	
			<p:dataTable id="role_data_table" value="#{roleBean.lazyData}"
				var="data" paginator="true" rows="10" paginatorPosition="bottom"
				paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
				currentPageReportTemplate="{currentPage}/{totalPages}"
				selectionMode="single" selection="#{roleBean.instance}"
				emptyMessage="#{msgs.emptyResult}">
				<f:facet name="header">角色信息列表
					<div style="text-align: right; position: relative; margin: -13px -5px 0px 0px; vertical-align: middle">
						<p:commandButton value="#{msgs.btnNew}" icon="#{comm.newClass}"
							actionListener="#{roleBean.initAddRole}" update=":role_edit_dialog"
							oncomplete="role_edit_var.show();" disabled="#{!roleBean.permission.add}">
							<f:setPropertyActionListener target="#{roleBean.model}" value="#{comm.m_a}"/>
							<f:setPropertyActionListener target="#{roleBean.summary}" value="添加角色信息：" />
						</p:commandButton>
					</div>
				</f:facet>
	
				<p:column headerText="编号" style="width: 10%; text-align: center;">
					#{data.code}
				</p:column>
				<p:column headerText="名称" style="width: 30%; text-align: center;">
					#{data.name}
				</p:column>
				<p:column headerText="#{msgs.valid}" style="width: 5%; text-align: center;">
					#{data.status == 1 ? msgs.valid_y : msgs.valid_n}
				</p:column>
				<p:column headerText="资源备注">
					#{data.note}
				</p:column>
				<p:column headerText="操作" style="width: 10%;">
					<p:commandButton title="#{msgs.btnQuery}" icon="#{comm.queryClass}" 
						 oncomplete="role_edit_var.show();" update=":role_edit_dialog"
						 disabled="#{!roleBean.permission.query}">
						<f:setPropertyActionListener target="#{roleBean.model}" value="#{comm.m_q}" />
						<f:setPropertyActionListener target="#{roleBean.summary}" value="查询角色信息：" />
						<f:setPropertyActionListener target="#{roleBean.instance}" value="#{data}"/>
					</p:commandButton>
					<p:commandButton title="#{msgs.btnEdit}" icon="#{comm.editClass}"
						oncomplete="role_edit_var.show();" update=":role_edit_dialog"
						disabled="#{!roleBean.permission.modify}">
						<f:setPropertyActionListener target="#{roleBean.model}" value="#{comm.m_m}" />
						<f:setPropertyActionListener target="#{roleBean.summary}" value="编辑角色信息：" />
						<f:setPropertyActionListener target="#{roleBean.instance}" value="#{data}"/>
					</p:commandButton>
					<p:commandButton title="分配用户角色" icon="#{comm.allotClass}" action="#{roleBean.initRoleUsers}"
						update=":role_user_edit_form" oncomplete="role_user_edit_var.show();"
						disabled="#{!roleBean.permission.communicate}">
						<f:setPropertyActionListener target="#{roleBean.instance}" value="#{data}" />
						<f:setPropertyActionListener target="#{roleBean.summary}" value="分配用户角色：" />
					</p:commandButton>
				</p:column>
			</p:dataTable>
		</h:form>
	</ui:define>
	
	<ui:define name="edit_content">
		<ui:include src="/faces/common/role/role_edit.xhtml" />
		<ui:include src="/faces/common/role/role_user_edit.xhtml" />
		<ui:include src="/faces/components/user_query_component.xhtml" />
	</ui:define>
</ui:composition>